<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<#include "head.html">
<title>抖音视频下载</title>
</head>
<body>
<article class="page-container">
<!-- 	<form action="${contextPath}/dy/api/getVideo.do" method="post" class="form form-horizontal" id="form"> -->
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">抖音视频链接：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" required  name="shareUrl" id="shareUrl">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3" style="margin-top: 1rem;">
				<input class="btn btn-primary radius" type="button" id="getVideo"  onclick="getVideo(this)" value="&nbsp;&nbsp;解析&nbsp;&nbsp;">
			</div>
		</div>
<!-- 	</form> -->
</article>

<#include "footer.html">

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript">
$(function(){
	
	
	
    $('.skin-minimal input').iCheck({
        checkboxClass: 'icheckbox-blue',
        radioClass: 'iradio-blue',
        increaseArea: '20%'
    })
    
    

	/* $("#form").validate({
		rules:{
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			var options = {  
					url:$("#form").attr("action"),
	                success: function() {
	                	layer.alert('解析成功', function(index){
	  	                	var index = parent.layer.getFrameIndex(window.name);
	  	        			parent.$("[name='refresh']").click();
	  	        			window.location.href="/douyinVideo/golist.do";
	                	});    
	                	
	                }   
	        }; 
			$(form).ajaxSubmit(options);
		}
	}); */
});


function getVideo(obj){
	//检测到视频链接
	var http=$("#shareUrl").val();
	http=http.substring(http.indexOf("http"), http.lastIndexOf('/'));
	console.log(http);
	
	$(obj).removeAttr("onclick").text("解析中....");
	$('#getVideo').attr('disabled','disabled');
	$.ajax({
			type:"post",
			url:"${contextPath}/dy/api/getVideo.do",
			data:{shareUrl:http},
			success:function(data){
				$(obj).attr("onclick","getVideo(this)").text("解析");
				layer.alert('解析成功', function(index){
	              	var index = parent.layer.getFrameIndex(window.name);
	      			parent.$("[name='refresh']").click();
	      			$('#getVideo').removeAttr("disabled");
	      			window.location.href="/douyinVideo/golist.do";
	        	});  
			},
			error:function(data) {
				$(obj).attr("onclick","getVideo(this)").text("解析");
	            layer.alert(data.msg||"解析失败");
	        }
	});
}

</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>